#include <iostream>
using namespace std;
#define MaxSize 50

typedef struct intStack
{
    int data[MaxSize];
    int top = -1;
} IS;

bool push(IS *stack, int n)
{
    if (stack->top == MaxSize - 1)
        return false;
    stack->data[++stack->top] = n;
    return true;
}

int pop(IS *stack)
{
    if (stack->top == -1)
        return -1;
    else if (stack->top == 0)
        return stack->data[stack->top--];
    
    return stack->data[--stack->top];
}

int top(IS *stack)
{
    if (stack->top == -1)
        return -1;
    return stack->data[stack->top];
}
IS *init()
{
    IS *stack = new IS();
    push(stack, 2);
    printf("%d,%d\n", pop(stack), top(stack));
    push(stack, 2);
    push(stack, 2);
    push(stack, 2);
    return stack;
}
int main(int argc, char const *argv[])
{
    IS *s = init();
    printf("%d,%d", pop(s), top(s));
    return 0;
}
